import Vue from 'vue'
import VueRouter from 'vue-router'
import manage from './manage'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/large-screen-management/index'
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/Login')
  },
  {
    path: '/403',
    component: () => import('@/components/page/403'),
    meta: { title: '403' }
  },
  {
    path: '*',
    name: '404',
    component: () => import('@/components/page/404'),
    meta: { title: '404' }
  },
  ...manage,
]

const router = new VueRouter({
  // mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

// 全局路由守卫
router.beforeEach((to,from,next)=>{
  let title=to.meta.title
  document.title=title?title:'后台管理系统'
  // if(to.path!='/login'){
  //   next('/login')
  // }else{
  //   next()
  // }
  next()
})

export default router
